//
//  ZJMineApplicationOneTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/8.
//

#import "ZJMineApplicationOneTableViewCell.h"

@interface ZJMineApplicationOneTableViewCell()

@property (nonatomic, strong) UIView * bgView;
@property (nonatomic, strong) UILabel * titleLabel;
@property (nonatomic, strong) UILabel * typeLabel;
@property (nonatomic, strong) UILabel * nameLabel;
@property (nonatomic, strong) UILabel * complayLabel;
@property (nonatomic, strong) UILabel * timeLabel;
@end



@implementation ZJMineApplicationOneTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.contentView.backgroundColor = COLOR_RGB(244, 244, 244);
        [self configUI];
        
    }
    return self;
}



-(void)setModel:(MineApplicationModel *)model{
    _model = model;
    self.titleLabel.text = model.processDefinitionName ?: @"";
    self.typeLabel.text = model.currentActivityName ?: @"";
    self.nameLabel.text = model.StartUsers.name ?: @"";
    self.complayLabel.text = model.StartUsers.companyName ?: @"";
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy.MM.dd HH:mm:ss"];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[model.startTime doubleValue]/1000];
    self.timeLabel.text = [formatter stringFromDate:date] ?: @"";
}



-(void)setGoodsModel:(MineGoodsTransferModel *)goodsModel{
    _goodsModel = goodsModel;
    
    self.titleLabel.text = @"工具货物转单";
    NSString *typeStr = @"";
    
    switch (goodsModel.type) {
        case 0:
            typeStr = @"待审批";
            break;
        case 1:
            typeStr = @"已同意";
            break;
        case 2:
            typeStr = @"已拒绝";
            break;
        default:
            break;
    }
    self.typeLabel.text = typeStr;
    self.nameLabel.text = [NSString stringWithFormat:@"接单人：%@",goodsModel.fromUserName];
    self.complayLabel.text = [NSString stringWithFormat:@"所属公司：%@",goodsModel.fromUserCompanyName];
    self.timeLabel.text = goodsModel.transferTime ?: @"";
    
    
    
}




-(void)configUI{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.typeLabel];
    [self.bgView addSubview:self.nameLabel];
    [self.bgView addSubview:self.complayLabel];
    [self.bgView addSubview:self.timeLabel];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(12));
        make.right.equalTo(self.contentView).with.offset(-ALIGN_WIDTH_PT(12));
        make.top.equalTo(self.contentView).with.offset(ALIGN_HEIGHT_PT(5));
        make.bottom.equalTo(self.contentView).with.offset(-ALIGN_HEIGHT_PT(5));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).with.offset(ALIGN_WIDTH_PT(10));
        make.top.equalTo(self.bgView).with.offset(ALIGN_HEIGHT_PT(17));
    }];
    
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleLabel.mas_centerY);
        make.right.equalTo(self.bgView).with.offset(-ALIGN_WIDTH_PT(10));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(10));
    }];
    
    [self.complayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.nameLabel.mas_bottom);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.complayLabel.mas_bottom);
    }];
    
    
}


#pragma mark -- 懒加载
-(UIView *)bgView{
    if (!_bgView){
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 10;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

-(UILabel *)titleLabel{
    if (!_titleLabel){
        _titleLabel = [UILabel new];
        _titleLabel.text = @"长期人员通行证申办";
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = [UIFont systemFontOfSize:15 weight:0.3];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

-(UILabel *)typeLabel{
    if (!_typeLabel){
        _typeLabel = [UILabel new];
        _typeLabel.text = @"考试合格";
        _typeLabel.textAlignment = NSTextAlignmentRight;
        _typeLabel.font = FONT12;
        _typeLabel.textColor = COLOR_RGB(50, 113, 237);
    }
    return _typeLabel;
}


-(UILabel *)nameLabel{
    if (!_nameLabel){
        _nameLabel = [UILabel new];
        _nameLabel.text = @"赵庄镇";
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = FONT14;
        _nameLabel.textColor = COLOR_RGB(102, 102, 102);
    }
    return _nameLabel;
}

-(UILabel *)complayLabel{
    if (!_complayLabel){
        _complayLabel = [UILabel new];
        _complayLabel.text = @"机场超市分公司";
        _complayLabel.textAlignment = NSTextAlignmentLeft;
        _complayLabel.font = FONT14;
        _complayLabel.textColor = COLOR_RGB(102, 102, 102);
    }
    return _complayLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel){
        _timeLabel = [UILabel new];
        _timeLabel.text = @"2024.10.25 14:31:32";
        _timeLabel.textAlignment = NSTextAlignmentLeft;
        _timeLabel.font = FONT14;
        _timeLabel.textColor = COLOR_RGB(102, 102, 102);
    }
    return _timeLabel;
}



@end
